﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ExtendedReflection.Metadata;

namespace DUCover.Core
{   
    

    /// <summary>
    /// Represents an entity such as local variable or member variable 
    /// declared in the program 
    /// </summary>
    public class DeclEntity
    {
        DeclEntityKey key;

        public enum EntityType { FIELD_TYPE };
        private EntityType entityType;

        private FieldDefinition fd;
        
        public DeclEntity(FieldDefinition fd)
        {
            this.key = new DeclEntityKey(fd.GlobalIndex);
            this.entityType = EntityType.FIELD_TYPE;
            this.fd = fd;
        }

        public override bool Equals(object obj)
        {
            if (obj is DeclEntity)
            {
                return this.key.Equals((obj as DeclEntity).key);
            }
            return false;
        }

        public override int GetHashCode()
        {
            return this.key.GetHashCode();
        }

        public override string ToString()
        {
            switch (this.entityType)
            {
                case EntityType.FIELD_TYPE:
                    return fd.ToString();
                default:
                    return "Unknown";
            }   
        }
    }
}
